package com.woorigil.social.worker.task;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;

import org.springframework.stereotype.Component;

import com.woorigil.social.domain.deal.DealListDocument;
import com.woorigil.social.parser.Parser;

@Component
public class DealLoadProcessor {

	public DealListDocument process(Parser parser) throws Exception {
		InputStream is = new FileInputStream(parser.getSourcePath());
		Reader reader = new BufferedReader(new InputStreamReader(is, parser.getCharsetName()));
		DealListDocument dealListDocument = parser.parse(reader);
		return dealListDocument;
	}
}
